package com.example.resolve.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * ClassName:ReceiveMessage
 * Package:com.example.problem01.message
 * Description:
 *
 * @Author:ZhangXin
 * @Create:2023/8/13-20:56
 * @Version:v1.0
 */
@Component
@Slf4j
public class ReceiveMessage {

    private static final String queueDlxName = "queue.delay.dlx.3";

    /**
     * 延迟队列接收死信队列消息
     */
    @RabbitListener(queues = queueDlxName)
    public void receiveMsg(Message message) {
        String body = new String(message.getBody());

        log.info("接收到的消息为:{},接收时间为:{}", body, new Date());
    }

}
